package org.ashin.log;

import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import freemarker.template.TemplateExceptionHandler;
import org.ashin.App;
import org.ashin.log.bean.ServiceInfo;

import java.io.File;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;

public class LogTemplate {

    public static void main(String[] args) throws IOException, TemplateException {
        Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);

        cfg.setDirectoryForTemplateLoading(new File(App.class.getResource("/template").getFile()));
        cfg.setDefaultEncoding("UTF-8");
        cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);


        Template temp = cfg.getTemplate("log.ftl");

        Writer out = new OutputStreamWriter(System.out);
        temp.process(ServiceInfo.builder().ns("worktest2").service("vv-org-service-test5").build(), out);
        System.out.println();
    }
}
